import request from '@/util/request'
import type { HotDetailRes, SuggestionSearchRes, CommonSearchRes } from '@/types/song/index'

/**
 * 热搜接口包含详细信息
 * @returns
 */
export const hotSearch = async () => {
  return await request.get<HotDetailRes>(`/search/hot/detail`)
}

/**
 * 搜索建议
 * @param keywords 关键词
 * @param type  如果传 'mobile' 则返回移动端数据
 * @returns
 */
export const suggestSearch = async (keywords: string, type?: string) => {
  return await request.get<SuggestionSearchRes>(`/search/suggest?keywords=${keywords}&type=${type}`)
}

/**
 * 通用搜索
 * @param keywords 关键字
 * @param limit 分页条数
 * @param offset 分页数
 * @param type 类型
 *    默认为 1 即单曲 , 取值意义 : 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频, 1018:综合
 * @returns
 */
export const commonSearch = async (keywords: string, limit: number = 20, offset: number = 0, type: number = 1) => {
  return await request.get<CommonSearchRes>(`/search?keywords=${keywords}&limit=${limit}&offset=${offset}&type=${type}`)
}
